﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DCTAccess.Business;
using DCTLib.Common;
using System.Data;

namespace DCTAccess.Business.Administrator
{
    public class Administrator : User
    {
        private int _role = -1;               

        public Administrator(string loginName, string originalPassword)
        {
            UserName = loginName;
            HashedPassword = MD5Helper.GetMD5Hash(originalPassword);
        }

        public Administrator() { }

        public Administrator(DataRow adminInfo)
        {
            this.ID = Convert.ToInt32(adminInfo["AdminID"].ToString());
            this.UserName = adminInfo["AdminLoginName"].ToString();
            this.HashedPassword = adminInfo["HashedPassword"].ToString();
            this.FullName = adminInfo["FullName"].ToString();
            this.Mobile = adminInfo["Mobile"].ToString();
            this.Address = adminInfo["Address"].ToString();
            this.Email = adminInfo["Email"].ToString();
            this.RegDate = adminInfo["RegDate"].ToString();
            this.LastLoginDate = adminInfo["LastLoginDate"].ToString();

            try
            {
                this.Disable = Convert.ToBoolean(adminInfo["Disable"].ToString());
            }
            catch
            {
                this.Disable = false;
            }
            if (adminInfo["Role"].ToString().Length > 0)
                Role = int.Parse(adminInfo["Role"].ToString());
        }

        #region Properties
        public string RegDate
        {
            get { return _regDate; }
            set { _regDate = value; }
        }

        public string Birthday
        {
            get { return _birthday; }
            set { _birthday = value; }
        }
        public string Address
        {
            get { return _address; }
            set { _address = value; }
        }


        public string Mobile
        {
            get { return _mobile; }
            set { _mobile = value; }
        }

        public int Role
        {
            get { return _role; }
            set { _role = value; }
        }

        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }

        public string UserName
        {
            get { return _userName; }
            set { _userName = value; }
        }

        public string HashedPassword
        {
            get { return _hashedPassword; }
            set { _hashedPassword = value; }
        }

        public string FullName
        {
            get { return _fullName; }
            set { _fullName = value; }
        }

        public string Email
        {
            get { return _email; }
            set { _email = value; }
        }

        public string LastLoginDate
        {
            get { return _lastLoginDate; }
            set { _lastLoginDate = value; }
        }

        public bool Disable
        {
            get { return _disable; }
            set { _disable = value; }
        }
        #endregion
    }
}
